package com.ruoyi.project.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.system.domain.LiveRoom;
import com.ruoyi.project.system.service.ILiveRoomService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 直播间数据Controller
 * 
 * @author david
 * @date 2025-06-11
 */
@RestController
@RequestMapping("/data/live_room")
public class LiveRoomController extends BaseController
{
    @Autowired
    private ILiveRoomService liveRoomService;

    /**
     * 查询直播间数据列表
     */
    @PreAuthorize("@ss.hasPermi('data:live_room:list')")
    @GetMapping("/list")
    public TableDataInfo list(LiveRoom liveRoom)
    {
        startPage();
        List<LiveRoom> list = liveRoomService.selectLiveRoomList(liveRoom);
        return getDataTable(list);
    }

    /**
     * 导出直播间数据列表
     */
    @PreAuthorize("@ss.hasPermi('data:live_room:export')")
    @Log(title = "直播间数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LiveRoom liveRoom)
    {
        List<LiveRoom> list = liveRoomService.selectLiveRoomList(liveRoom);
        ExcelUtil<LiveRoom> util = new ExcelUtil<LiveRoom>(LiveRoom.class);
        util.exportExcel(response, list, "直播间数据数据");
    }

    /**
     * 获取直播间数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('data:live_room:query')")
    @GetMapping(value = "/{liveRoomId}")
    public AjaxResult getInfo(@PathVariable("liveRoomId") String liveRoomId)
    {
        return success(liveRoomService.selectLiveRoomByLiveRoomId(liveRoomId));
    }

    /**
     * 新增直播间数据
     */
    @PreAuthorize("@ss.hasPermi('data:live_room:add')")
    @Log(title = "直播间数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LiveRoom liveRoom)
    {
        return toAjax(liveRoomService.insertLiveRoom(liveRoom));
    }

    /**
     * 修改直播间数据
     */
    @PreAuthorize("@ss.hasPermi('data:live_room:edit')")
    @Log(title = "直播间数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LiveRoom liveRoom)
    {
        return toAjax(liveRoomService.updateLiveRoom(liveRoom));
    }

    /**
     * 删除直播间数据
     */
    @PreAuthorize("@ss.hasPermi('data:live_room:remove')")
    @Log(title = "直播间数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{liveRoomIds}")
    public AjaxResult remove(@PathVariable String[] liveRoomIds)
    {
        return toAjax(liveRoomService.deleteLiveRoomByLiveRoomIds(liveRoomIds));
    }
}
